using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SalesPages.DomainModel;


namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class E1ContentValueMap : EntityTypeConfiguration<E1ContentValue>
    {
        public E1ContentValueMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Value_id, t.SiteVersion });

            // Properties
            this.Property(t => t.Value_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.SiteVersion)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.KeyValue)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.CityCode)
                .HasMaxLength(50);

            this.Property(t => t.SchoolCode)
                .HasMaxLength(50);

            this.Property(t => t.PartnerCode)
                .HasMaxLength(50);

            this.Property(t => t.MarketCode)
                .HasMaxLength(50);

            this.Property(t => t.Area)
                .HasMaxLength(100);

            this.Property(t => t.ServerName)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("E1ContentValue");
            this.Property(t => t.Value_id).HasColumnName("Value_id");
            this.Property(t => t.SiteVersion).HasColumnName("SiteVersion");
            this.Property(t => t.Variable_id).HasColumnName("Variable_id");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.KeyValue).HasColumnName("KeyValue");
            this.Property(t => t.CityCode).HasColumnName("CityCode");
            this.Property(t => t.SchoolCode).HasColumnName("SchoolCode");
            this.Property(t => t.PartnerCode).HasColumnName("PartnerCode");
            this.Property(t => t.MarketCode).HasColumnName("MarketCode");
            this.Property(t => t.Area).HasColumnName("Area");
            this.Property(t => t.ServerName).HasColumnName("ServerName");
            this.Property(t => t.BeginDate).HasColumnName("BeginDate");
            this.Property(t => t.EndDate).HasColumnName("EndDate");
            this.Property(t => t.Development).HasColumnName("Development");
            this.Property(t => t.InsertDate).HasColumnName("InsertDate");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");

            // Relationships
            this.HasRequired(t => t.E1ContentVariable)
                .WithMany(t => t.E1ContentValue)
                .HasForeignKey(d => new { d.Variable_id, d.SiteVersion });

        }
    }
}
